package com.ruoyi.system.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.service.TranslationService;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhengyz
 * @date 2025/7/11
 */
@Service
@RequiredArgsConstructor
public class TranslationServiceImpl implements TranslationService {

    public static final String SEPARATOR = ",";

    private final SysUserMapper sysUserMapper;

    @Override
    public String userIdsToNickname(String userIds) {
        List<String> list = new ArrayList<>();
        LambdaQueryWrapper<SysUser> lqw = new LambdaQueryWrapper<>();
        lqw.select(SysUser::getNickName);
        lqw.in(SysUser::getUserId, StringUtils.splitTo(userIds, Convert::toLong));
        List<SysUser> userlist = sysUserMapper.selectList(lqw);
        for (SysUser sysUser : userlist) {
            list.add(sysUser.getNickName());
        }
        return String.join(SEPARATOR, list);
    }

    @Override
    public String userIdsToUserName(String userIds) {
        List<String> list = new ArrayList<>();
        LambdaQueryWrapper<SysUser> lqw = new LambdaQueryWrapper<>();
        lqw.select(SysUser::getUserName);
        lqw.in(SysUser::getUserId, StringUtils.splitTo(userIds, Convert::toLong));
        List<SysUser> userlist = sysUserMapper.selectList(lqw);
        for (SysUser sysUser : userlist) {
            list.add(sysUser.getNickName());
        }
        return String.join(SEPARATOR, list);
    }

    @Override
    public String dataTypeToLabel(String dataType, String value) {
        return DictUtils.getDictLabel(dataType, value);
    }

    @Override
    public String ossIdsToUrl(String ossIds) {
        return "";
    }
}
